Skip to content

docs: sync dialect tabs across pages#672

Open
binit2-1 wants to merge 1 commit into
drizzle-team:mainfrom
binit2-1:docs/sync-dialect-tabs
Open

docs: sync dialect tabs across pages#672
binit2-1 wants to merge 1 commit into
drizzle-team:mainfrom
binit2-1:docs/sync-dialect-tabs

Conversation

@binit2-1
Copy link
Copy Markdown

Summary

Adds shared state for dialect tabs in the docs.

When a user selects a dialect tab such as SQLite, MySQL, or PostgreSQL, matching dialect tabs on the same page now switch to the same option. The selected dialect is also reflected in the URL query param, for example ?dialect=sqlite, so loading the page with that query preselects matching tabs.

Fixes drizzle-team/drizzle-orm#4963

Changes

  • Added shared dialect tab sync logic in src/utils-client.ts
  • Wired Tabs.astro and CodeTabs.astro to use the shared helper
  • Kept non-dialect tabs local, so tabs like schema.ts, index.ts, or package manager tabs do not sync accidentally

Verification

  • pnpm run build passed
  • Manually verified /docs/indexes-constraints?dialect=sqlite
  • Confirmed selecting MySQL updates matching tab groups and changes the URL to ?dialect=mysql

Demo

demo.mp4

Attached a short video showing dialect tabs syncing across the page.

Copilot AI review requested due to automatic review settings May 12, 2026 13:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds client-side shared state so “dialect” tabs (e.g., SQLite/MySQL/PostgreSQL) stay in sync across tab groups on the same docs page, and reflects the selected dialect in the URL query string for deep-linking.

Changes:

  • Introduced setupSyncedTabs() in src/utils-client.ts to normalize dialect labels, sync matching tab groups, and write ?dialect=... to the URL.
  • Updated Tabs.astro and CodeTabs.astro to provide stable data-tab-label values and delegate tab behavior to the shared helper.
  • Ensured non-dialect tab groups still behave locally (only recognized dialect labels participate in syncing).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/utils-client.ts Adds dialect normalization, tab activation helpers, and URL query param syncing via setupSyncedTabs().
src/mdx/Tabs.astro Adds data-tab-label and switches tab click handling to setupSyncedTabs().
src/mdx/CodeTabs.astro Adds data-tab-label and switches tab click handling to setupSyncedTabs().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/utils-client.ts
const updateDialectQueryParam = (dialect: string) => {
const url = new URL(window.location.href);
url.searchParams.set(dialectParam, dialect);
window.history.replaceState({}, "", `${url.pathname}${url.search}${url.hash}`);
Comment thread src/utils-client.ts
Comment on lines +247 to +253
const matchingButton = Array.from(parent.children).find((child) => {
return getTabButtonDialect(child as HTMLElement) === dialect;
}) as HTMLElement | undefined;

if (matchingButton) {
activateTabButton(matchingButton);
tabGroups.add(parent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[DOCS]: Connect all tabs together

2 participants